﻿using System.Linq;
using System.Web.Mvc;
using System.Collections.Generic;

using ASPNETMVCApplication.Code.Filters;
using ASPNETMVCApplication.Repositories;
using ASPNETMVCApplication.ActionServiceReference;
using ASPNETMVCApplication.Code.HtmlHelpers;
using ASPNETMVCApplication.Controllers;
using ASPNETWebApplication;
using ASPNETMVCApplication.Areas.Supp.Models;
using System.Web;

namespace ASPNETMVCApplication.Areas.Supp.Controllers
{
    /// <summary>
    /// Controller class for the Shopping area.
    /// </summary>
    public class EmployeeController : BaseController
    {
        private IEmployeeRepository _employeeRepository;

        public EmployeeController()
            : this(new EmployeeRepository())
        {
        }

        /// <summary>
        /// Overloaded 'injectable' Constructor for ShopController.
        ///
        /// Pattern: Constructor Dependency Injection (DI).
        /// </summary>
        /// <param name="categoryRepository"></param>
        /// <param name="productRepository"></param>
        /// <param name="cartRepository"></param>
        public EmployeeController(IEmployeeRepository employeeRepository)
        {
            _employeeRepository = employeeRepository;
        }

        [Menu(MenuItem.Supplier)]
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult ERegister()
        {
            List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem { Text = "Nam", Selected = true, Value = "0" });
            items.Add(new SelectListItem { Text = "Nữ", Value = "1" });
            ViewData["sex"] = items;
            return View();
        }
        //register account supplier
        [HttpPost]
        public ActionResult ERegister(EmployeeModel employeeModel)
        {
            employeeModel.SupplierId = (int)Session["suppId"];
            HttpPostedFileBase postedFile = Request.Files["pictureUrl"];
            employeeModel.Picture = postedFile.FileName;
            var employee = Mapper.FromModel(employeeModel);
            _employeeRepository.Insert(employee);
            List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem { Text = "Nam", Selected = true, Value = "0" });
            items.Add(new SelectListItem { Text = "Nữ", Value = "1" });
            ViewData["sex"] = items;
            return View(employeeModel);
        }
    }
}


